<?php
namespace app\mobile\model;
use think\Model;
class Destine extends model{
   
    /*
     * 获取定制主题
     * $start   开始位置
     * $limit   获取的记录数
     */
    public function getDestineCase($start = 0,$limit=0){
        if(empty($limit)){
            $result = M('goods')->alias('a')
            ->field('a.*,b.*,c.title as aromaname,e.title as themetitle,f.suppliers_name')
            ->join('destine_goods_attr b','a.goods_id=b.goods_id')
            ->join('destine_aroma c','b.aroma_id=c.id')
            ->join('destine_theme e','b.theme_id=e.id')
            ->join('suppliers f','f.suppliers_id=b.winery_id')
            ->join('origin g','g.id=f.origin_id')->where("a.type =2 and a.is_on_sale =1")->limit($start)->select();
        }else{
            $result = M('goods')->alias('a')
            ->field('a.*,b.*,c.title as aromaname,e.title as themetitle,f.suppliers_name')
            ->join('destine_goods_attr b','a.goods_id=b.goods_id')
            ->join('destine_aroma c','b.aroma_id=c.id')
            ->join('destine_theme e','b.theme_id=e.id')
            ->join('suppliers f','f.suppliers_id=b.winery_id')
            ->join('origin g','g.id=f.origin_id')->where("a.type =2 and a.is_on_sale =1")->limit($start,$limit)->select();
        }
        return $result;
    }

}
?>    